// JavaScript Document
var windowbrow=navigator.appName;
  var windowtype;
  if (windowbrow.indexOf("Netscape")!=-1)
  {
     windowtype=1;
     //alert("you are using Netscape(Mozilla) family browser,good!");
     }   
  if (windowbrow.indexOf("Microsoft")!=-1)
  {
     //isIE=1;
     windowtype=0;
     //alert("You are using Microsoft's Internet Explorer browser,Opps,shit!");
  }   

// retrieve XML document (reusable generic function);
// parameter is URL string (relative or complete) to
// an .xml file whose Content-Type is a valid XML
// type, such as text/xml; XML source must be from
// same domain as HTML file
function loadXMLDoc(url,tfunc,ffunc) {
	var req;

    // branch for native XMLHttpRequest object
    if (window.XMLHttpRequest) {
        req = new XMLHttpRequest();
        //req.OnReadyStateChange = processReqChange(req);//,tfunc,ffunc);
        req.open("GET", url, false);
        req.send(null);
    // branch for IE/Windows ActiveX version
    } else if (window.ActiveXObject) {
        isIE = true;
        req = new ActiveXObject("Microsoft.XMLHTTP");
        if (req) {
            //req.OnReadyStateChange = processReqChange(req);//,tfunc,ffunc);
            req.open("GET", url, false);
            req.send();
        }
    }
	return req;
}

// handle onreadystatechange event of req object
function processReqChange(req) { //,tfunc,ffunc) {
	// only if req shows "loaded"
	if (req.readyState == 4) {
		// only if "OK"
		if (req.status == 200) {
		//execScript(tfunc, "javascript")
		} else {
		// execScript(ffunc, "javascript")
		}
	}
}

function decode_utf8(utftext) {
    var plaintext = ""; var i=0; var c=c1=c2=0;
    while(i<utftext.length)
        {
        c = utftext.charCodeAt(i);
        if (c<128) {
            plaintext += String.fromCharCode(c);
            i++;}
        else if((c>191) && (c<224)) {
            c2 = utftext.charCodeAt(i+1);
            plaintext += String.fromCharCode(((c&31)<<6) | (c2&63));
            i+=2;}
        else {
            c2 = utftext.charCodeAt(i+1); c3 = utftext.charCodeAt(i+2);
            plaintext += String.fromCharCode(((c&15)<<12) | ((c2&63)<<6) | (c3&63));
            i+=3;}
        }
    return plaintext;
}
function setCookie(name,value,expiry,path,domain,secure){
	var nameString = name + '=' + escape(value);
	var expiryString = (expiry == null) ? '' : ' ;expires = '+ expiry.toGMTString();
	var pathString = (path == null) ? '' : ' ;path = '+ path;
	var domainString = (domain == null) ? '' : ' ;domain = '+ domain;
	var secureString = (secure) ?';secure':'';
	document.cookie = nameString + expiryString + pathString + domainString + secureString;
}
function getCookie() {
	if (arguments.length==2){

		var CookieFound = false;
		var CookieString = getCookie(arguments[0]);

		var aCookieString=CookieString.split('&');
		for (var i=0;i<aCookieString.length;i++){
			j=aCookieString[i].indexOf('=');
			if (arguments[1]==aCookieString[i].substring(0,j))
				return unescape(aCookieString[i].substr(j+1));
		}
	} else {
		var CookieFound = false;
		var CookieString = document.cookie;

		var aCookieString=CookieString.split('; ');
		for (var i=0;i<aCookieString.length;i++){
			j=aCookieString[i].indexOf('=');
			if (arguments[0]==aCookieString[i].substring(0,j))
				return unescape(aCookieString[i].substr(j+1));
		}
	}
	return '';
}
function deleteCookie(name){
	var expires = new Date();
	expires.setTime (expires.getTime() - 1);
	setCookie( name , "Delete Cookie", expires,null,null,false);
}
function urlencode_gb2utf8(rawtext) {
    rawtext = rawtext.replace(/\r\n/g,"\n");
    var utftext = "";
    for(var n=0; n<rawtext.length; n++)
        {
        //
        var c=rawtext.charCodeAt(n);
        // 0-127 => 1byte
        if (c<128)
            utftext += escape(String.fromCharCode(c));    
        // 127 - 2047 => 2byte
        else if((c>127) && (c<2048)) {
            utftext += escape(String.fromCharCode((c>>6)|192));
            utftext += escape(String.fromCharCode((c&63)|128));}
        // 2048 - 66536 => 3byte
        else {
            utftext += escape(String.fromCharCode((c>>12)|224));
            utftext += escape(String.fromCharCode(((c>>6)&63)|128));
            utftext += escape(String.fromCharCode((c&63)|128));}
        }
    return utftext;
}